package Application.FirstApplication.manager
{
	import Application.FirstApplication.def.Def;
	import Application.FirstApplication.def.Manager;
	import Application.FirstApplication.view.scene.HomeScene;
	import Application.FirstApplication.view.scene.PreLoadingMed;
	
	import def.XG;

	public class SceneManager
	{
		public var group : Object;
		private var m_lashScene : *;
		
		public static const SceneId_PreLoading : int = 0;
		public static const SceneId_MapMedit : int = 1;
		public static const SceneId_HomeMap : int = 2;
		
		public function SceneManager()
		{
			
		}
		
		public function IntoScene(sceneId : int) : void
		{
			switch(sceneId)
			{
				case 0:
					intoPreLoadingScene();
					break;
				case 1:
					intoMapEditScene();
					break;
				case 2: 
					intoHomeMapScene();
					break;
			}
		}
		
		/**预加载场景**/
		private function intoPreLoadingScene():void
		{
			
			XG.openUI(Def.PreloadingScene,PreLoadingMed);
			
			Manager.Source.loadGameSource(loadSourceCallBack);
		}
		
		/***资源加载回调*/
		private function loadSourceCallBack() : void
		{	
			XG.closeUI(Def.PreloadingScene);
			
			Manager.Stage.init();
		}
		
		/** 
		 * 地图编辑场景
		 */		
		private function intoMapEditScene() : void
		{
			
		}
		
		private function intoHomeMapScene() : void
		{
			clearScene();
			
			m_lashScene = new HomeScene;
		}
		
		private function clearScene() : void
		{
			if(m_lashScene)
			{
				m_lashScene.destory();
			}
		}
	}
}